草庐IT

c++ - Float32 和 UInt32?

全部标签

c - RegQueryValueEx()读取REG_DWORD时总是在*lpData中填0

我对RegQueryValueEx()函数有疑问当我使用它时,它用0填充*lpDataLONGWINAPIRegQueryValueEx(_In_HKEYhKey,_In_opt_LPCTSTRlpValueName,_Reserved_LPDWORDlpReserved,_Out_opt_LPDWORDlpType,_Out_opt_LPBYTElpData,_Inout_opt_LPDWORDlpcbData);这是不起作用的代码#include#includeintmain(){HKEYhKey=NULL;DWORDdata=42;DWORDtype=REG_DWORD;DWOR

c# - 如何仅通过 Win32 API 实现 .NET Process.Exited 事件

在C#上,很容易检测到特定进程ID是否已退出。Processp=Process.GetProcessById(pid);p.Exited+=newEventHandler(OnExited);如果只用Win32API写出与此相同的操作,我该怎么办? 最佳答案 您执行此操作的方式与.NETProcess类执行此操作的方式完全相同。使用RegisterWaitForSingleObject()在进程句柄上。当句柄收到信号(即进程完成)或可选超时到期时,您的回调将运行。请记住,与.NET一样,回调在theadpool线程上运行,因此需要适

c - 未使用 MinGW 编译的 Winsock 服务器代码

以下是来自http://msdn.microsoft.com/en-us/library/windows/desktop/ms737593(v=vs.85).aspx的winsock服务器代码#undefUNICODE#defineWIN32_LEAN_AND_MEAN#include#include#include#include#include//NeedtolinkwithWs2_32.lib#pragmacomment(lib,"Ws2_32.lib")//#pragmacomment(lib,"Mswsock.lib")#defineDEFAULT_BUFLEN512#def

windows - 如何在 win32 控制台上解析 "printf"而不是 "_printf"的符号?

测试平台是windows32bit。所以基本上我想在这些命令中汇编+链接一段汇编代码:nasm-fwin32test.scltest.obj/linkmsvcrt.lib它说:errorLNK2001:unresolvedexternalsymbolprintf在我的代码中,我确实有这样的函数调用:callprintf所以我把这些都改成了call_printf而且有效。我对windows编程不熟悉,请问有什么方法可以解析printf的外部符号吗?因为我在做一些自动转换的任务,转换所有以_开头的函数调用应该很繁琐...谁能给我一些帮助..?谢谢! 最佳答案

c - 如何检查套接字上是否有数据可用?

SOCKETs;//CreateaSOCKETforlisteningfor//incomingconnectionrequests.SOCKETnew_socket;//createasocketforacceptingincomingconnectionuint16port=18001;voidCreateSocket(){intsin_size;WSADATAwsa;structsockaddr_inserver,master;//creatingasocketaddressstructure:structurecontainsipaddressandportnumberprin

c++ - timeEndPeriod 是恢复之前的值还是默认值?

假设默认计时器分辨率为15毫秒。鉴于这种情况:ProcessAcallstimeBeginPeriod(1);Nowtimerresolutionis1ms.ProcessBcallstimeBeginPeriod(2);Nowtimerresolutionis2ms.ProcessBcallstimeEndPeriod(2);那么定时器分辨率是多少?它会回落到1毫秒还是15毫秒?让我们稍微修改一下场景:ProcessAcallstimeBeginPeriod(1);Nowtimerresolutionis1ms.ProcessBcallstimeBeginPeriod(2);Nowt

windows - windows中将64位地址截断为32位地址时,为什么要保证高33位为0,高32位不为0?

我一直在通过JeffreyRichter的C/C++阅读Windows,并在有关将32位应用程序移植到64位环境的Windows内存架构的章节中看到以下片段。Ifthesystemcouldsomehowguaranteethatnomemoryallocationswouldeverybemadeabove0x00000000'7FFFFFFF,theapplicationwouldworkfine.Truncatinga64bitaddresstoa32bitaddresswhenthehigh33bitsare0causesnoproblemwhatsoever.我无法理解为什么

c - 在 vtbl 中命名函数指针

抱歉,初学者的问题。在非常好的文章中CominplainC我读到这句话:OnerequirementofaCOMobjectisthatthefirstthreemembersofourVTable(i.e.,ourIExampleVtblstruct)mustbecalledQueryInterface,AddRef,andRelease.这是真的吗?如果更改名称,但参数、调用约定和返回值将相同怎么办?你还在做这个吗?如果不是,为什么?非常感谢您的回复。(正面或负面。) 最佳答案 每个COM接口(interface)都必须派生自I

c - 无法在 Windows 8 上使用 MinGW 执行 execl()

我有一个文件hello.exe,文件路径是D:\test\hello.exe,这是一个简单的helloworld程序(测试ok)。我还有一个程序proc.c,文件路径是D:\test\proc.c,代码如下:#include#include#include#include#include#includemain(intargc,char*argv[]){intret;ret=execl("D:\\test\\hello.exe","D:\\test\\hello.exe");if(ret==-1)printf("%d:\t%s",ret,errno);}程序挂起(windows对话框显

c++ - 使用 Win32/C++ API 更改 Windows 7 墙纸(操作未实现异常)

以下代码适用于Windows8.1(已测试)但不适用于Windows7。std::wstringloc=L"C:\\Users\User\\Desktop\\wallpaper.jpg";BOOLret=SystemParametersInfo(SPI_SETDESKWALLPAPER,0,(PVOID)loc.c_str(),SPIF_UPDATEINIFILE);当我在Windows7上运行该程序时,出现以下异常:First-chanceexceptionat0x76E3C41F(KernelBase.dll)inMyApp.exe:0xC0000002:Therequestedo